/**
 * @company : 版权所属 四川北星惯牌科技有限公司
 * @contact : 刘经理 19326416371
 **/
import {$Api} from "@/api";
import {
	userInfoStore
} from "@/stores/user";
export const useLogout = async () => {
	const userStore = userInfoStore();
	uni.showLoading({
		title: '正在退出登录'
	})
	const res = await $Api.login.logout()
	if (res.code == '1') {
		uni.removeStorageSync('user_token');
		userStore.userInfo = null;
		userStore.accountInfo = null;
		uni.showToast({
			title: '退出成功',
		})
		setTimeout(() => {
			uni.reLaunch({
				url: '/pages/login/login'
			})
			uni.hideLoading();
		}, 800)
		// console.log(userStore.userInfo, uni.getStorageSync('user_token'));
	} else {
		uni.hideLoading();
		uni.showToast({
			title: res.msg,
			icon: 'none'
		})
	}

}